# coding:utf-8
from __future__ import absolute_import
import argparse
from glob import glob
import os
from .download_img import main
import logging

file_patterns = [
    'china*.txt',


]


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-s', '--save-path', default='data/china')
    parser.add_argument('-l', '--limit', default=10000, type=int)
    parser.add_argument('--china-convert', default=True, type=bool)
    return parser.parse_args()


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    args = parse_args()
    all_file = []
    for file_pattern in file_patterns:
        all_file.extend(glob(os.path.join(args.save_path, file_pattern)))
    # logging.info(all_file)
    for file in all_file:
        args.xml_file = file
        args.img_dir = args.save_path
        args.class_dir_name, _ = os.path.splitext(os.path.basename(args.xml_file))
        logging.info("Now:" + file)
        main(args)
